package com.midian.model.advice;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.midian.common.utils.StringUtil;
import com.midian.model.common.BaseModel;
import com.midian.model.user.User;
import com.midian.service.user.IUserService;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Type;

import com.vividsolutions.jts.geom.Point;

/**
 * 建议表
 * 
 */
@Entity
@Table(name = "advice")
public class Advice extends BaseModel {
	/** 反馈内容 */
	private String content;
	/** 用户实体对象 */
	@ManyToOne(optional = true,fetch=FetchType.LAZY)
	@JoinColumn(name = "userId")
	@NotFound(action = NotFoundAction.IGNORE)
	private User user;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * 帐号描述信息
	 * 
	 * @return
	 */
	@Transient
	public String getAccountDesc() {
		String accountDesc = "";
		if (this.user != null) {

			if (IUserService.USER_FROM_NORMAL.equals(user.getUserfrom()) && StringUtils.isNotBlank(user.getAccount())) {
				accountDesc = user.getAccount();
			} else if (IUserService.USER_FROM_QQ.equals(user.getUserfrom())) {
				accountDesc = "QQ用户";
			} else if (IUserService.USER_FROM_WECHAT.equals(user.getUserfrom())) {
				accountDesc = "微信用户";
			}
		}
		return accountDesc;
	}

	/**反馈详情提示*/
	@Transient 
	public String getAdviceContentTips(){
		String adviceContentTips = "";
		if(StringUtils.isNotBlank(this.content)){
			adviceContentTips = StringUtil.replaceToHtmlQuot(this.content);
		}
		return adviceContentTips;
	}
}
